let utils = data["utils"];
let STUtil = data["STUtil"];
let Node = data["Node"];
let SplayTree = data["SplayTree"];
let isInBbox = data["isInBbox"];
let getBboxOverlap = data["getBboxOverlap"];
let cmp = data["cmp"];
let crossProduct = data["crossProduct"];
let dotProduct = data["dotProduct"];
let compareVectorAngles = data["compareVectorAngles"];
let sineOfAngle = data["sineOfAngle"];
let cosineOfAngle = data["cosineOfAngle"];
let closestPoint = data["closestPoint"];
let horizontalIntersection = data["horizontalIntersection"];
let verticalIntersection = data["verticalIntersection"];
let intersection = data["intersection"];
let perpendicular = data["perpendicular"];
let rounder = data["rounder"];
let geomIn = data["geomIn"];
let Segment = data["Segment"];

console.log("10PolygonClipping_geom-out01");

var geomOut = {};
function SweepEvent(point, isLeft) {
  void 0 === point.events ? point.events = [this] : point.events.push(this), this.point = point, this.isLeft = isLeft
}

function RingOut(events) {
  this.events = events;
  for (let i = 0, iMax = events.length; i < iMax; i++) events[i].segment.ringOut = this;
  this.poly = null
}
RingOut.factory = function (allSegments) {
  const ringsOut = [];
  for (let i = 0, iMax = allSegments.length; i < iMax; i++) {
    const segment = allSegments[i];
    if (!segment.isInResult() || segment.ringOut) continue;
    let prevEvent = null,
      event = segment.leftSE,
      nextEvent = segment.rightSE;
    const events = [event],
      startingPoint = event.point,
      intersectionLEs = [];
    for (; prevEvent = event, event = nextEvent, events.push(event), event.point !== startingPoint;)
      for (; ;) {
        const availableLEs = event.getAvailableLinkedEvents();
        if (0 === availableLEs.length) {
          const firstPt = events[0].point,
            lastPt = events[events.length - 1].point;
          throw new Error(`Unable to complete output ring starting at [${firstPt.x},` + ` ${firstPt.y}]. Last matching segment found ends at` + ` [${lastPt.x}, ${lastPt.y}].`)
        }
        if (1 === availableLEs.length) {
          nextEvent = availableLEs[0].otherSE;
          break
        }
        let indexLE = null;
        for (let j = 0, jMax = intersectionLEs.length; j < jMax; j++)
          if (intersectionLEs[j].point === event.point) {
            indexLE = j;
            break
          } if (null !== indexLE) {
            const intersectionLE = intersectionLEs.splice(indexLE)[0],
              ringEvents = events.splice(intersectionLE.index);
            ringEvents.unshift(ringEvents[0].otherSE), ringsOut.push(new RingOut(ringEvents.reverse()));
            continue
          }
        intersectionLEs.push({
          index: events.length,
          point: event.point
        });
        const comparator = event.getLeftmostComparator(prevEvent);
        nextEvent = availableLEs.sort(comparator)[0].otherSE;
        break
      }
    ringsOut.push(new RingOut(events))
  }
  return ringsOut
};





geomOut["RingOut"] = RingOut;

return {
  "utils": utils,
  "STUtil": STUtil,
  "Node": Node,
  "SplayTree": SplayTree,
  "isInBbox": isInBbox,
  "getBboxOverlap": getBboxOverlap,
  "cmp": cmp,
  "crossProduct": crossProduct,
  "dotProduct": dotProduct,
  "compareVectorAngles": compareVectorAngles,
  // "length":length,
  "sineOfAngle": sineOfAngle,
  "cosineOfAngle": cosineOfAngle,
  "closestPoint": closestPoint,
  "horizontalIntersection": horizontalIntersection,
  "verticalIntersection": verticalIntersection,
  "intersection": intersection,
  "perpendicular": perpendicular,
  "rounder": rounder,
  "geomIn": geomIn,
  "geomOut": geomOut,
  "Segment": Segment,
  "SweepEvent": SweepEvent
}